<script>

//Types in JavaScript fall into two categories: primitives and objects. 
//Primitive types include:String,Number,Boolean,null,undefined

/////// String ///////
// Strings can be created with double or single quotes.
var a = "I am a string";
var b = 'So am I!';

//Sometimes a string may contain quotation marks.
var statement1 = 'He said "JavaScript is awesome!"';
var statement2 = "He said \"JavaScript is awesome!\"";
/////////////////////


/////// Number ///////
//Numbers are any whole or floating point integer.
var num1 = 100;
var num2 = 100.10;
var num3 = 0.10;
/////////////////////


/////// Boolean ///////
//Boolean values.
var okay = true;
var fail = false;
/////////////////////


/////// null and undefined ///////
//Define a null value. Null types are values that represent the absence of a value
var foo = null;
 
// Undefined types represent a state in which no value has been assigned at all. 
//This type is created in two ways: by using the undefined keyword or by not defining a value at all.
var bar1 = undefined;
var bar2;
/////////////////////////////////


//////////// Objects ////////////
//Creating an object with the constructor:
var person1 = new Object; 
person1.firstName = "John";
person1.lastName = "Doe";
console.log(person1.firstName + " " + person1.lastName);
 
// Creating an object with the object literal syntax:
var person2 = {
    firstName: "Jane",
    lastName: "Doe"
};
console.log(person2.firstName + " " + person2.lastName );

//objects can also have objects as a property.
var people = {}; 
people[ "person1" ] = person1;
people[ "person2" ] = person2; 
console.log(people[ "person1" ].firstName );
console.log(people[ "person2" ].firstName );

//Properties that have not been created are undefined.
var person = { name: "John Doe" };
console.log(person.email ); // undefined
/////////////////////////////////


//////////// Array ////////////
//Creating an array with the constructor:
var foo = new Array;
 
// Creating an array with the array literal syntax:
var bar = [];

//The array literal returns a foo.length value of 1:
var foo = [ 100 ];
console.log(foo[ 0 ] ); // 100
console.log(foo.length ); // 1
 
// The array constructor returns a bar.length value of 100:
var bar = new Array( 100 );
console.log(bar[ 0 ] ); // undefined
console.log(bar.length ); // 100

// Using the push(), pop(), unshift() and shift() methods on an array. 
var foo = []; 
foo.push( "a" );
foo.push( "b" ); 
console.log(foo[ 0 ] ); // a
console.log(foo[ 1 ] ); // b 
console.log(foo.length ); // 2 
foo.pop(); 
console.log(foo[ 0 ] ); // a
console.log(foo[ 1 ] ); // undefined 
console.log(foo.length ); // 1 
foo.unshift( "z" ); 
console.log(foo[ 0 ] ); // z
console.log(foo[ 1 ] ); // a 
console.log(foo.length ); // 2 
foo.shift(); 
console.log(foo[ 0 ] ); // a
console.log(foo[ 1 ] ); // undefined 
console.log(foo.length ); // 1
////////////////////////



// Using JavaScript's typeof operator to test for primitive types: 
var myValue = [ 1, 2, 3 ];
console.log(typeof myValue === "string"); // false
console.log(typeof myValue === "number"); // false
console.log(typeof myValue === "undefined"); // false
console.log(typeof myValue === "boolean"); // false
console.log(typeof myValue === "object"); // true
 
// Using strict equality operator to check for null:
console.log(myValue === null); // false

</script>